import request from '@/utils/request';

export async function login(data, headers) {
  return request({
    url: '/mb/logins',
    unNeedToken: true,
    method: 'POST',
    data,
    headers,
  });
}

export async function getLoginCode(data) {
  return request({
    url: '/notification/codes/login',
    method: 'POST',
    unNeedToken: true,
    data,
  });
}

//服务端不再维护，前端停止使用，改为使用/mb/logins
export async function getOpenId(data) {
  const { code, source = 2 } = data; //添加参数source用来给服务端动态绑定小程序appid和secret，source=1 亨通，source=2 太湖吉市
  return request({
    url: `/product/wechat/getOpenId/${code}?source=${source}`,
    method: 'GET',
  });
}

export async function loginOut() {
  return request({
    url: '/mb/logins',
    method: 'DELETE',
  });
}
